package com.atguigu.mycloud.controller;

import com.atguigu.mycloud.Enum.ReturnMessage;
import com.atguigu.mycloud.service.SotrageService;
import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 任浩
 * @version 1.0
 */

@RestController
public class StorageController {
    @Resource
    private SotrageService storageService;

    /**
     * 扣减库存
     */
    @PostMapping(value = "/storage/decrease")
    public ReturnMessage decrease(@RequestParam("productId") Long productId, @RequestParam("count") Integer count) {

        storageService.decrease(productId, count);
        return ReturnMessage.success("扣减库存成功!");
    }
}
